Parse.Cloud.define('validateSmsCode', async (req, res) => {
  const { id, code } = req.params
  if (!id || !code) {
    return res.error('参数不正确')
  }
  try {
    const query = new Parse.Query('AuthCode')
    const result = await query.get(id)
    if (code === result.get('code')) {
      res.success({
        code: 1
      })
      await result.destroy()
    } else {
      res.success({
        code: -1
      })
    }
  } catch (err) {
    console.log(err)
    res.error(err.message)
  }
})
